<template>
  <div class="app-container">
    <el-form
    :append-to-body="false"
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="分析项目" prop="fxxm">
        <el-input
          v-model="queryParams.fxxm"
          placeholder="请输入分析项目"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报告日期" prop="bgrq">
        <el-input
          v-model="queryParams.bgrq"
          placeholder="请输入报告日期"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['Laboratory_fgd:fgdreport:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['Laboratory_fgd:fgdreport:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['Laboratory_fgd:fgdreport:remove']"
          >删除</el-button
        >
      </el-col>
   <!--    <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Laboratory_fgd:fgdreport:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-s-check"
          size="mini"
          :disabled="multiple"
          @click="handleCheck"
          v-hasPermi="['Laboratory_fgd:fgdreport:check']"
          >审核</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="fgdreportList"
      @selection-change="handleSelectionChange"
      max-height="550"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="100px" />
      <el-table-column label="报告日期" align="center" prop="bgrq" />
      <el-table-column
        label="分析项目"
        align="center"
        prop="fxxm"
        :formatter="laboratory_Fgdreport_fxxm_Format"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.fxxm }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检验员" align="center" prop="jyy">
        <template slot-scope="scope">
          <span>{{ scope.row.jyy }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核人" align="center" prop="shrPerson">
        <template slot-scope="scope">
          <span>{{ scope.row.shrPerson }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="250px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="excelhandleView(scope.row)"
          >导出</el-button            >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >查看</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['Laboratory_fgd:fgdreport:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['Laboratory_fgd:fgdreport:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改分光度报表对话框 -->
    <el-dialog v-myFullscreen
      fullscreen
      v-loading="isLoading"
      element-loading-text="正在加载..."
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0.8)"
      :title="title"
      :visible.sync="open"
      width="700px"
      custom-class="myDialog"
      append-to-body
    >
      <TableHeader
        @nameChange="nameChange"
        :data="{
          mainTitle: '分光度法检验原始记录',
          company: '青岛崂山矿泉水有限公司',
          code: form.bbbh,
        }"
      />
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="分析项目" prop="fxxm">
                <el-select
                  v-model="form.fxxm"
                  placeholder="请选择分析项目"
                  :disabled="openDisabled"
                  @change="fxxmCascade"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in laboratory_Fgdreport_fxxm"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictLabel"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="检测依据" prop="jcyj">
                <el-input
                  v-model="form.jcyj"
                  placeholder="请输入检测依据"
                  :disabled="openDisabled"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="12">
            <el-form-item label="检测方法" prop="jcff">
              <el-input
                v-model="form.jcff"
                placeholder="请输入检测方法"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-row>
              <el-col :span="13">
                <el-form-item label="试验环境：温度℃" prop="wd">
                  <el-input
                    v-model="form.wd"
                    placeholder="请输入温度"
                    :disabled="openDisabled"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="湿度%" prop="sd" label-width="60px">
                  <el-input
                    v-model="form.sd"
                    placeholder="请输入湿度"
                    :disabled="openDisabled"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>

          <el-col :span="12">
            <!-- <el-form-item label="检测日期" prop="jcrq">
                  <el-input v-model="form.jcrq" placeholder="请输入检测日期" :disabled="openDisabled" />
                </el-form-item> -->
            <el-form-item label="检测日期" prop="jcrq">
              <el-date-picker
                clearable
                :editable="false"
                v-model="form.jcrq"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择检测日期"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告日期" prop="bgrq">
              <el-date-picker
                clearable
                :editable="false"
                v-model="form.bgrq"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择报告日期"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仪器名称" prop="yqmc">
              <el-input
                v-model="form.yqmc"
                placeholder="请输入仪器名称"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仪器型号" prop="yqxh">
              <el-input
                v-model="form.yqxh"
                placeholder="请输入仪器型号"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标液浓度(ug/mL)" prop="bynd">
              <el-input
                v-model="form.bynd"
                placeholder="请输入标液浓度"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="波长、比色皿" prop="bcbsm">
              <el-input
                v-model="form.bcbsm"
                placeholder="请输入波长比色皿"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="取样量(mL)" prop="qyl">
              <el-input
                v-model="form.qyl"
                placeholder="请输入取样量"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="定容体积(mL)" prop="drtj">
              <el-input
                v-model="form.drtj"
                placeholder="请输入定容体积"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" placeholder="请输入备注" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
        </el-row>

        <!-- 分光度报表1信息 -->
        <br />
        <el-divider content-position="center">分光度报表1信息</el-divider>
        <br />
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddReportSub1"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteReportSub1"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-table
          :data="reportSub1List"
          :row-class-name="rowReportSub1Index"
          @selection-change="handleReportSub1SelectionChange"
          ref="reportSub1"
          border
          max-height="550"
        >
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column  label="序号" align="center" prop="index" width="50"/> -->
          <el-table-column label="标准系列  序号" prop="xh">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.xh"
                placeholder="请输入序号"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="加标量(mL)" prop="jbl">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.jbl"
                placeholder="请输入加标量"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="吸光度X(A)" prop="xgd">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.xgd"
                placeholder="请输入吸光度"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="浓度y(mg/L)" prop="nd">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.nd"
                placeholder="请输入浓度"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- 计算参数 -->
        <el-row>
          <el-col :span="24">
            <el-form-item label="计算参数" prop="jscs">
              <el-input
                v-model="form.jscs"
                placeholder="请输入计算参数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="计算公式" prop="jsgs">
              <el-input
                v-model="form.jsgs"
                placeholder="请输入计算公式"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <br />
        <el-divider content-position="center">分光度报表2信息</el-divider
        ><!-- 分光度报表2信息 -->
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddReportSub2"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteReportSub2"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-table
          :data="reportSub2List"
          :row-class-name="rowReportSub2Index"
          @selection-change="handleReportSub2SelectionChange"
          border
          ref="reportSub2"
        >
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column label="序号" align="center" prop="index" width="50"/> -->
          <el-table-column label="样品名称" prop="ypmc">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.ypmc"
                placeholder="请输入样品名称"
                :disabled="openDisabled"
              />
              <!-- <Dialog
                @dialogChange="dialogChange($event, scope)"
                :echoValue="scope.row.ypmc"
                parameter="rows"
                value="id"
                label="name"
                :multiple="false"
                search="name/code"
                url="/basic/productInfo/listSelect"
                :column="['产成品编号/code', '产成品名称/name']"
                placeholder="请选择内容"
                :axiosData="{ typeCode: 'YYTRKQS' }"
                :openDisabled="openDisabled"
              /> -->
            </template>
          </el-table-column>
          <el-table-column label="生产批次/取样日期" prop="scpc">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.scpc"
                placeholder="请输入生产批次/取样日期"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="吸光度(A)" prop="xgd">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.xgd"
                placeholder="请输入吸光度"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="样品结果(mg/L)" prop="ypjg">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.ypjg"
                placeholder="请输入样品结果"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>

          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <el-row class="mb8">
          <div label="备注">
            备注:&nbsp;&nbsp; 以下情况需要重新绘制标准曲线：<br />
            1、标准溶液使用2个月；<br />
            2、更换配套的溶液；<br />
            3、分光光度计出故障检修后。<br />
            要求相关系数r值三个九以上。
          </div>
        </el-row>
        <br />
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核人" prop="shrPerson">
              <el-input
                v-model="form.shrPerson"
                :disabled="true"

              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检验员" prop="jyy">
              <!-- <el-input
                v-model="form.jyy"
                placeholder="请输入检验员"
                :disabled="openDisabled"
              /> -->
              <el-select
                v-model="form.jyy"
                filterable
                allow-create
                placeholder="请选择检验员"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="item in userList"
                  :key="item.nickName"
                  :label="item.nickName"
                  :value="item.nickName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listFgdreport,
  getFgdreport,
  delFgdreport,
  addFgdreport,
  updateFgdreport,
    checkFgdreport
} from "@/api/quality/laboratory/fgdreport";
import { getInfo } from "@/api/login";
import { listUser } from "@/api/system/user";
import { listType } from "../../../../../api/system/dict/type";

export default {
  name: "Fgdreport",
  data() {
    return {
      //弹窗是否禁止编辑
      openDisabled: true,
      // 遮罩层
      loading: true, // 是否加载遮罩层
      isLoading: false,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedReportSub1: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 分光度报表表格数据
      fgdreportList: [],
      // 分光度报表表格数据
      reportSub1List: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        fxxm: null,
        bgrq: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      reportSub1List: [],
      reportSub2List: [],
      laboratory_Fgdreport_fxxm: [],
      /* 当前用户名 */
      nickName: "",
      userList: [],
    };
  },
  created() {
    this.getList();
    this.queryUserList();
    this.getDicts("laboratory_Fgdreport_fxxm").then((response) => {
      this.laboratory_Fgdreport_fxxm = response.data;
    });
    this.getDicts("laboratory_Fgdreport_ad").then((response) => {
      this.laboratory_Fgdreport_ad = response.data;
    });
  },
  methods: {
    dialogChange(event, scope) {
      // this.reportSub2List[scope.$index].ypmc = event.options.code;
      this.reportSub2List[scope.$index].ypmc = event.label;
    },
    /** 查询分光度报表列表 */
    getList() {
      this.loading = true;
      listFgdreport(this.queryParams).then((response) => {
        this.fgdreportList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 故障类型字典翻译
    laboratory_Fgdreport_fxxm_Format(row, column) {
      return this.selectDictLabel(this.laboratory_Fgdreport_fxxm, row.sjmc);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        //fxxm: null,
        //jcyj: this.laboratory_Fgdreport_ad[0].dictValue,
        //jcff: this.laboratory_Fgdreport_ad[1].dictValue,
        wd: null,
        sd: null,
        jcrq: null,
        bgrq: null,
        //yqmc: this.laboratory_Fgdreport_ad[2].dictValue,
        //yqxh: this.laboratory_Fgdreport_ad[3].dictValue,
        //bynd: this.laboratory_Fgdreport_ad[4].dictValue,
        //bcbsm: this.laboratory_Fgdreport_ad[5].dictValue,
        qyl: null,
        drtj: null,
        remark: null,
        bbbh: "LK-QF-LS1-10-012-11-01",
        shrPerson: null,
        jyy: this.nickName,
        jsgs: null,
        jscs: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
      };
      this.reportSub1List = [];
      this.reportSub2List = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openDisabled = false;
      this.open = true;
      this.title = "添加分光度报表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.openDisabled = false;
      const id = row.id || this.ids;
      getFgdreport(id).then((response) => {
        this.form = response.data;
        this.reportSub1List = response.data.reportSub1List;
        this.reportSub2List = response.data.reportSub2List;
        this.open = true;
        this.title = "修改分光度报表";
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.reset();
      this.openDisabled = true;
      const id = row.id || this.ids;
      getFgdreport(id).then((response) => {
        // console.log(response)
        this.form = response.data;
        this.reportSub1List = response.data.reportSub1List;
        this.reportSub2List = response.data.reportSub2List;
        this.open = true;
        this.title = "查看分光度报表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          /* 打开遮罩层 */
          this.isLoading = true;
          this.form.reportSub1List = this.reportSub1List;
          this.form.reportSub2List = this.reportSub2List;
          if (this.form.id != null) {
            updateFgdreport(this.form)
              .then((response) => {
                /* 请求成功后执行关闭遮罩层 */
                this.isLoading = false;
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .catch((error) => {
                /* 请求异常后执行关闭遮罩层 */
                this.isLoading = false;
              });
          } else {
            addFgdreport(this.form)
              .then((response) => {
                this.msgSuccess("新增成功");
                this.open = false;
                /* 请求成功后执行关闭遮罩层 */
                this.isLoading = false;
                this.getList();
              })
              .catch((error) => {
                /* 请求异常后执行关闭遮罩层 */
                this.isLoading = false;
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除分光度报表编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delFgdreport(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 分光度报表序号 */
    rowReportSub1Index({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 分光度报表1添加按钮操作 */
    handleAddReportSub1() {
      let obj = {};
      obj.xh = this.reportSub1List.length+1;
      obj.jbl = "";
      obj.xgd = "";
      obj.nd = "";
      this.reportSub1List.push(obj);
    },
    /** 分光度报表删除按钮操作 */
    handleDeleteReportSub1() {
      if (this.checkedReportSub1.length == 0) {
        this.$alert("请先选择要删除的分光度报表数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.reportSub1List.splice(this.checkedReportSub1[0].index - 1, 1);
      }
    },
    /** 单选框选中数据 */
    handleReportSub1SelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.reportSub1.clearSelection();
        this.$refs.reportSub1.toggleRowSelection(selection.pop());
      } else {
        this.checkedReportSub1 = selection;
      }
    },

    /** 风光度报表2序号 */
    rowReportSub2Index({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 风光度报表2添加按钮操作 */
    handleAddReportSub2() {
      let obj = {};
      obj.ypmc = "";
      obj.xgd = "";
      obj.ypjg = "";
      obj.scpc = "";
      obj.remark = "";
      this.reportSub2List.push(obj);
    },
    /** 风光度报表2删除按钮操作 */
    handleDeleteReportSub2() {
      if (this.checkedReportSub2.length == 0) {
        this.$alert("请先选择要删除的风光度报表2数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.reportSub2List.splice(this.checkedReportSub2[0].index - 1, 1);
      }
    },
    /** 单选框选中数据 */
    handleReportSub2SelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.reportSub2.clearSelection();
        this.$refs.reportSub2.toggleRowSelection(selection.pop());
      } else {
        this.checkedReportSub2 = selection;
      }
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "Laboratory_fgd/fgdreport/export",
        {
          ...this.queryParams,
        },
        `Laboratory_fgd_fgdreport.xlsx`
      );
    },
    excelhandleView(row){
      this.download(
        "Laboratory/fgdreport/exportexcel?id="+row.id,
        {
          ...this.queryParams,
        },
        "分光度法检验原始记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    /*excelhandleView(row){
      this.download(
        "Laboratory/fgdreport/exportexcel?id="+row.id,
        {
          ...this.queryParams,
        },
        "分光度法检验原始记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },*/
    //接收编号
    nameChange(e) {
      this.form.bbbh = e;
    },

    /** 分析项目关联操作 */
    fxxmCascade(row) {
      /* 查询字典类型列表 */
      listType().then((response) => {
        response.rows.forEach((dictItem) => {
          if (
            dictItem.remark === "分析项目关联项" &&
            row === dictItem.dictName
          ) {
            this.getDicts(dictItem.dictType).then((xmglx) => {
              // 查询分析项目
              this.reportSub1List = [];
              this.form = {
                fxxm: row,
                bbbh: "LK-QF-LS1-10-012-11-01",
                jyy: this.nickName,
                // jcyj: xmglx.data[8].dictValue,
                // jcff: xmglx.data[9].dictValue,
                // yqmc: xmglx.data[10].dictValue,
                // yqxh: xmglx.data[11].dictValue,
                // bynd: xmglx.data[12].dictValue,
                // bcbsm: xmglx.data[13].dictValue,
                jcyj:'',
                jcff: '',
                yqmc: '',
                yqxh: '',
                bynd: '',
                bcbsm:'',
              };
              let num = 0;
              xmglx.data.forEach((item) => {
                num = num + 1;
                if (num <= 8) {
                  let obj = {};
                  obj.xh = num;
                  obj.jbl = item.remark;
                  // obj.xgd = item.dictLabel;
                  obj.xgd=null;
                  obj.nd = item.dictValue;
                  this.reportSub1List.push(obj);
                }
              });
              this.resetForm("form");
            });
          }
          // if(dictItem.remark === '分析项目关联项'){
          //   // 根据类型查字典
          //   this.getDicts(dictItem.dictType).then((xmglx) => {
          //     // 查询分析项目
          //     this.laboratory_Fgdreport_fxxm.forEach((xm)=>{
          //       if(row === xm.dictLabel && dictItem.dictName === row){
          //         this.form = {
          //           fxxm: row,
          //           bbbh: "LK-QF-LS1-10-012-11-01",
          //           jyy: this.nickName,
          //           jcyj: xmglx.data[8].dictValue,
          //           jcff: xmglx.data[9].dictValue,
          //           yqmc: xmglx.data[10].dictValue,
          //           yqxh: xmglx.data[11].dictValue,
          //           bynd: xmglx.data[12].dictValue,
          //           bcbsm: xmglx.data[13].dictValue,
          //         };
          //         let num = 0;
          //         xmglx.data.forEach((item)=>{
          //           num = num + 1;
          //           if(num <= 8){
          //             let obj = {};
          //             obj.xh = num;
          //             obj.jbl = item.remark;
          //             obj.xgd = item.dictLabel;
          //             obj.nd = item.dictValue;
          //             this.reportSub1List.push(obj);
          //           }
          //         })
          //         this.resetForm("form");
          //       }
          //     })
          //   })
          // }
        });
      });
    },
    /** 审核按钮操作 */
    handleCheck(row) {
      /* 审核 */
      this.ids.forEach((id) => {
        getFgdreport(id).then((response) => {
          if (
            response.data.shrPerson != null &&
            response.data.shrPerson != ""
          ) {
            this.msgError(
              '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
            );
          } else {
            let obj = {};
            obj.id = id;
            obj.shrPerson = this.nickName;
            obj.reportSub1List = this.reportSub1List;
            obj.reportSub2List = this.reportSub2List;
            /* 修改 */
            checkFgdreport(obj).then((response) => {
              this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
              this.getList();
            });
          }
        });
      });
    },
    /* 查询用户列表 */
    queryUserList() {
      listUser().then((response) => {
        this.userList = response.rows;
      });
      getInfo().then((response) => {
        this.nickName = response.user.nickName;
      });
    },
  },
};
</script>
